import { useI18n } from '/@/hooks/web/useI18n';
import { BasicColumn, BasicTableProps, FormProps } from '/@/components/Table';
import {
  matMoreApplyFlListData,
} from '/@/api/m8/rd/apply/matMoreApply';

const { t } = useI18n('sys.basVen');

// 补料图纸选择
const modalProps = {
  title: t('补料申请选择'),
};

const searchForm: FormProps = {
  baseColProps: { lg: 6, md: 8 },
  labelWidth: 90,
  schemas: [
    {
      label: t('单据编号'),
      field: 'code',
      component: 'Input',
    },
    {
      label: t('图名'),
      field: 'orderPic.picname',
      component: 'Input',
    },
    {
      label: t('申请人'),
      field: 'createByName',
      component: 'Input',
    },
   
    
  ],
  fieldMapToTime: [['ddate', ['ddate_gte', 'ddate_lte']]],
};

const tableColumns: BasicColumn[] = [
  {
    title: t('单据日期'),
    dataIndex: 'ddate',
    key: 'a.ddate',
    sorter: true,
    width: 100,
    align: 'left',
  },
  {
    title: t('图名'),
    dataIndex: 'orderPic.picname',
    key: 'a.pic_id',
    sorter: true,
    width: 150,
    align: 'left',
  },
  {
    title: t('材料'),
    dataIndex: 'orderPic.cmat',
    width: 100,
    align: 'left',
  },
  {
    title: t('规格'),
    dataIndex: 'xlSize',
    width: 100,
    align: 'left',
  },
  
  {
    title: t('数量'),
    dataIndex: 'iqty',
    key: 'a.iqty',
    sorter: true,
    width: 80,
    align: 'center',
  },
  {
    title: t('剩余数量'),
    dataIndex: 'syPuQty',
    width: 80,
    align: 'center',
  },
  {
    title: t('补料说明'),
    dataIndex: 'remarks',
    key: 'a.remarks',
    sorter: true,
    width: 150,
    align: 'left',
  },
  {
    title: t('单据编号'),
    dataIndex: 'code',
    key: 'a.code',
    sorter: true,
    width: 150,
    align: 'left',
    slot: 'firstColumn',
  },
 
 
  
  {
    title: t('累计采购数'),
    dataIndex: 'sumPuQty',
    key: 'a.sum_pu_qty',
    sorter: true,
    width: 100,
    align: 'center',
  },
 
  {
    title: t('申请人'),
    dataIndex: 'createByName',
    key: 'a.create_by_name',
    sorter: true,
    width: 100,
    align: 'left',
  },

];

const tableProps: BasicTableProps = {
  api: matMoreApplyFlListData,
  beforeFetch: (params) => {
    params['isAll'] = true;
    return params;
  },
  columns: tableColumns,
  formConfig: searchForm,
  rowKey: 'id',
};

export default {
  modalProps,
  tableProps,
  itemCode: 'code',
  itemName: 'iqty',
};
